<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="certificate" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{certificateHome.managed ? 'Edit' : 'Add'} Certificate</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{certificateHome.managed}"
                          value="#{certificateHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="certificateNameField" template="layout/edit.xhtml">
                <ui:define name="label">Certificate name</ui:define>
                <h:inputText id="certificateName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{certificateHome.instance.certificateName}">
                    <a:support event="onblur" reRender="certificateNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="descriptionField" template="layout/edit.xhtml">
                <ui:define name="label">Description</ui:define>
                <h:inputTextarea id="description"
                               cols="80"
                               rows="10"
                              value="#{certificateHome.instance.description}"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{certificateHome.persist}"
                       disabled="#{!certificateHome.wired}"
                       rendered="#{!certificateHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{certificateHome.update}"
                       rendered="#{certificateHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{certificateHome.remove}"
                      immediate="true"
                       rendered="#{certificateHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Certificate.xhtml"
                rendered="#{certificateHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty certificateFrom ? 'CertificateList' : certificateFrom}.xhtml"
                rendered="#{!certificateHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Student cerficates">
        <h:form styleClass="association" id="studentCerficatesChildren">

            <h:outputText value="There are no studentCerficates associated with this certificate."
                       rendered="#{empty certificateHome.studentCerficates}"/>

            <rich:dataTable value="#{certificateHome.studentCerficates}"
                           var="_studentCerficate"
                      rendered="#{not empty certificateHome.studentCerficates}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentCerficatesTable">
                <rich:column sortBy="#{_studentCerficate.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentCerficate.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentCerficate.receivedStatus}">
                    <f:facet name="header">Received status</f:facet>
                    <h:outputText value="#{_studentCerficate.receivedStatus}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{certificateHome.managed}" id="studentCerficates">
        <div class="actionButtons">
            <s:button id="addstudentCerficate"
                   value="Add studentCerficate"
                    view="/StudentCerficateEdit.xhtml"
             propagation="none">
                 <f:param name="certificateId"
                         value="#{certificateHome.instance.id}"/>
                 <f:param name="studentCerficateFrom" value="Certificate"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
